package com.zjuee.web.company.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zjuee.base.dto.common.login.LoginDto;
import com.zjuee.base.enums.RedisCacheType;
import com.zjuee.core.translation.service.TranslateData;
import com.zjuee.core.translation.utils.CaseUtil;
import com.zjuee.service.company.service.CompanyLicenseGroupService;
import com.zjuee.service.company.vo.CompanyLicenseVo;
import com.zjuee.base.model.common.company.CompanyLicenseGroup;
import com.zjuee.web.company.mapper.CompanyLicenseGroupMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class CompanyLicenseGroupServiceImpl extends ServiceImpl<CompanyLicenseGroupMapper, CompanyLicenseGroup> implements CompanyLicenseGroupService {

    @Resource
    private CompanyLicenseGroupMapper licenseGroupMapper;

    @Resource
    private LoginDto loginDto;

    @Resource
    private TranslateData translateData;

    @Override
    public List<CompanyLicenseVo> getAllSDisposal(Long licenseId, String disposalType) {
        List<CompanyLicenseVo> companyLicenseVoList = licenseGroupMapper.
                getAllSDisposal(licenseId, disposalType);
        List<CompanyLicenseVo> licenseVoList = (List<CompanyLicenseVo>) CaseUtil
                .castList(translateData
                        .translateData(companyLicenseVoList, "companyLicenseListHandle",
                                String.valueOf(RedisCacheType.DISPOSE_STYPE)), CompanyLicenseVo.class);;
        //翻译数据
        return licenseVoList;
    }

    @Override
    public List<CompanyLicenseVo> getMinuteInfo(Long licenseId) {
        List<CompanyLicenseVo> licenseInfoList = licenseGroupMapper.
                getMinuteInfo(licenseId);
        List<CompanyLicenseVo> licenseVoList = (List<CompanyLicenseVo>) CaseUtil
                .castList(translateData
                        .translateData(licenseInfoList, "companyLicenseListHandle",
                                String.valueOf(RedisCacheType.DISPOSE_TYPE),
                                String.valueOf(RedisCacheType.DISPOSE_STYPE),
                                String.valueOf(RedisCacheType.DANGER_BCLASS)), CompanyLicenseVo.class);;
        //翻译数据
        return licenseVoList;
    }
}
